package com.community.manage.controller;

import com.community.common.entity.vo.UserLoginVo;
import com.community.common.result.Result;
import com.community.manage.service.UserService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/user")
@Log4j2
public class UserController {

    @Autowired
    UserService userService;

    @Autowired
    HttpServletRequest request;

    /**
     * 根据手机号查询用户
     * @return
     */
    @PostMapping("/findUserByPhone/{phone}")
    public Result<UserLoginVo> findUserByPhone(@PathVariable String phone){
        log.info("请求路径：【{}】，请求方式：【{}】，请求参数：【{}】",
                request.getRequestURI(),request.getMethod(),phone);

        Result result=userService.findUserByPhone(phone);
        log.info("请求路径：【{}】，请求方式：【{}】，响应结果：【{}】",
                request.getRequestURI(),request.getMethod(),result);
        return result;
    }

}
